<template>
	<view class="box bg-f7 padding-30">
		<view v-for="item in transformList">
			<transform :item="item" :isReservation='true'></transform>
		</view>
	</view>
</template>

<script>
	import transform from "@/components/transform/transform.vue";
	import {
		decorationList
	} from "@/api/elderlySuitable.js";
	export default {
		data() {
			return {
				transformList: [],
				page: 1,
				isMore: false
			}
		},
		components: {
			transform
		},
		onLoad() {
			this.init()
		},

		//上拉加载函数
		onReachBottom() { 
			if (this.isMore) {
				setTimeout(() => {
					this.getList()
				}, 100)
			} else {
				uni.showToast({
					title: '暂无更多',
					icon: 'none'
				})
			}

		},
		onPullDownRefresh() {
			//刷新初始化数据
			this.init()
			//关闭刷新动画
			setTimeout(function() {
				uni.stopPullDownRefresh()
			}, 1000)
		},
		methods: {
			init(){
				this.transformList = []
				 this.page = 1
				 this.getList()
			},
			getList() {
				let params = {
					page: this.page,
					limit: 10,
					type: 2
				}
				decorationList(params).then(res => {
					if (res.code == 1) {
						this.transformList = this.transformList.concat(res.data)
						if(res.data && res.data.length> 9){
							this.isMore= true
                            this.page++
						}else{
							this.isMore= false
						}
					} else {
						uni.showToast({
							icon: 'none',
							title: res.msg
						})
					}
				})
			}
		}
	}
</script>

<style>

</style>